<?php 

if (! defined('BASEPATH')) exit('No direct script access');

class Faculties extends Controller {

  //php 5 constructor
  function __construct() {
    parent::Controller();
    $this->load->model('Faculty');
  }
  
  //php 4 constructor
  function Faculties() {
    parent::Controller();
    $this->load->model('Faculty');
  }
  
  /**
   * Muestra una lista de departamentos por campus
   * Viene de la url listfaculties/:any/campus_id
   *
   * @param string $campus_id 
   * @return void
   * @author Ian Murray
   */
  function by_campus($campus_id) {
    /* El nombre e info del campus */
    $this->load->model('Campus');
    if ( ! $campus = $this->Campus->get_by_id($campus_id)) {
      $this->layouts->show_404();
    }
    else {
      /* Cargamos los departamentos del campus */
      $faculties = $this->Faculty->get(array(
        'fields' => '*',
        'where' => array('campus_id' => $campus_id),
        'order' => 'name asc'
      ));
    
      /* Los mostramos */
      $this->layouts->set_title($campus['name']);
      $this->layouts->view('faculties/by_campus', array('campus' => $campus, 'faculties' => $faculties));
    }
  }

}